package com.ruoyi.shopUserRelation.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shopUserRelation.mapper.UserShopRelationMapper;
import com.ruoyi.shopUserRelation.domain.UserShopRelation;
import com.ruoyi.shopUserRelation.service.IUserShopRelationService;

/**
 * 用户门店关联信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-11-18
 */
@Service
public class UserShopRelationServiceImpl implements IUserShopRelationService 
{
    @Autowired
    private UserShopRelationMapper userShopRelationMapper;

    /**
     * 查询用户门店关联信息
     * 
     * @param relationId 用户门店关联信息主键
     * @return 用户门店关联信息
     */
    @Override
    public UserShopRelation selectUserShopRelationByRelationId(Long relationId)
    {
        return userShopRelationMapper.selectUserShopRelationByRelationId(relationId);
    }

    /**
     * 查询用户门店关联信息列表
     * 
     * @param userShopRelation 用户门店关联信息
     * @return 用户门店关联信息
     */
    @Override
    public List<UserShopRelation> selectUserShopRelationList(UserShopRelation userShopRelation)
    {
        return userShopRelationMapper.selectUserShopRelationList(userShopRelation);
    }

    /**
     * 新增用户门店关联信息
     * 
     * @param userShopRelation 用户门店关联信息
     * @return 结果
     */
    @Override
    public int insertUserShopRelation(UserShopRelation userShopRelation)
    {
        userShopRelation.setCreateTime(DateUtils.getNowDate());
        return userShopRelationMapper.insertUserShopRelation(userShopRelation);
    }

    /**
     * 修改用户门店关联信息
     * 
     * @param userShopRelation 用户门店关联信息
     * @return 结果
     */
    @Override
    public int updateUserShopRelation(UserShopRelation userShopRelation)
    {
        userShopRelation.setUpdateTime(DateUtils.getNowDate());
        return userShopRelationMapper.updateUserShopRelation(userShopRelation);
    }

    /**
     * 批量删除用户门店关联信息
     * 
     * @param relationIds 需要删除的用户门店关联信息主键
     * @return 结果
     */
    @Override
    public int deleteUserShopRelationByRelationIds(Long[] relationIds)
    {
        return userShopRelationMapper.deleteUserShopRelationByRelationIds(relationIds);
    }

    /**
     * 删除用户门店关联信息信息
     * 
     * @param relationId 用户门店关联信息主键
     * @return 结果
     */
    @Override
    public int deleteUserShopRelationByRelationId(Long relationId)
    {
        return userShopRelationMapper.deleteUserShopRelationByRelationId(relationId);
    }

    /**
     * 根据用户id查询默认门店
     * @param userId
     * @return
     */
    @Override
    public UserShopRelation selectDefaultShopByUserId(Long userId) {

        return userShopRelationMapper.selectDefaultShopByUserId(userId);
    }
}
